import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:moose_app/ui/values/values.dart';

class ATHSearchHotItem extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: kSize60),
      constraints: BoxConstraints(maxHeight: kSize1120),
      child: ListView.builder(
          shrinkWrap: true,
          scrollDirection: Axis.horizontal,
          itemCount: 5,
          itemBuilder: (context, index) {
            return Container(
              width: kSize560,
              decoration: kCommonBoxDecoration,
              margin: EdgeInsets.only(right: kSize20),
              child: ListView.builder(
                  itemCount: 11,
                  shrinkWrap: true,
                  physics: NeverScrollableScrollPhysics(),
                  itemBuilder: (context, index) {
                    if (index == 0) {
                      return _buildTopTitleItem();
                    }
                    return _buildItem(index);
                  }),
            );
          }),
    );
  }

  Widget _buildItem(int index) {
    return Container(
      decoration:
          BoxDecoration(border: Border(bottom: BorderSide(color: kColorF1))),
      height: kSize100,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                  height: kSize38,
                  width: kSize38,
                  margin: EdgeInsets.symmetric(horizontal: kSize16),
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                      gradient:
                          LinearGradient(colors: [kColorFF9000, kColorFF5000]),
                      borderRadius: BorderRadius.all(Radius.circular(kSize8))),
                  child: Text(
                    "$index",
                    style: TextStyle(color: Colors.white),
                  )),
              Text(
                "今天吃饭了吗？",
                style: TextStyle(fontSize: kFontSize30),
              ),
              Container(
                  height: kSize38,
                  width: kSize38,
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(kSize8)),
                      border: Border.all(color: kColorFF9000)),
                  child: Text(
                    "热",
                    style:
                        TextStyle(fontSize: kFontSize24, color: kColorFF5000),
                    textAlign: TextAlign.center,
                  )),
            ],
          ),
          SvgPicture.asset(
            "assets/icons/icon_arrow_top.svg",
            width: kSize48,
            color: kColorFF5000,
          )
        ],
      ),
    );
  }

  Widget _buildTopTitleItem() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: kSize20),
      height: kSize120,
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(color: kColorF1),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              SvgPicture.asset(
                "assets/icons/icon_crown.svg",
                width: kSize38,
              ),
              Container(
                margin: EdgeInsets.symmetric(horizontal: kSize8),
                child: Text(
                  "Moose 热搜",
                  style: TextStyle(fontSize: kFontSize32, color: kColorFF5000),
                ),
              ),
              Text(
                "今日热搜全知道",
                style: TextStyle(fontSize: kFontSize28, color: kColorFF6200),
              )
            ],
          ),
          SvgPicture.asset(
            "assets/icons/icon_arrow_right.svg",
            width: kSize38,
            color: kColorFF9000,
          )
        ],
      ),
    );
  }
}
